#include "XiolVibrationMotorState.h"

#include <assert.H>

namespace Xiol
{

VibrationMotorState::VibrationMotorState()
{
	ZeroMemory( &mVibrationStruct, sizeof(XINPUT_VIBRATION) );
	mVibrationStruct.wLeftMotorSpeed = 0;
	mVibrationStruct.wRightMotorSpeed = 0;
}

VibrationMotorState::VibrationMotorState( const XINPUT_VIBRATION& vibrationStruct )
{
	CopyMemory( &mVibrationStruct, &vibrationStruct, sizeof(XINPUT_VIBRATION) );
}

VibrationMotorState::VibrationMotorState( const VibrationMotorState& other )
{
	CopyMemory( &mVibrationStruct, &other.mVibrationStruct, sizeof(XINPUT_VIBRATION) );
}
		
VibrationMotorState& VibrationMotorState::operator=( const VibrationMotorState& other )
{
	if ( &other==this )
		return (*this);
	CopyMemory( &mVibrationStruct, &other.mVibrationStruct, sizeof(XINPUT_VIBRATION) );
	return (*this);
}

WORD VibrationMotorState::getVibrationMotorSpeed( int motorID ) const
{
	if ( motorID==0 )
		return mVibrationStruct.wLeftMotorSpeed;
	else if ( motorID==1 )
		return mVibrationStruct.wRightMotorSpeed;
	assert(false);
	return 0;
}

void VibrationMotorState::setVibrationMotorSpeed( int motorID, WORD speed )
{
	if ( motorID==0 )
		mVibrationStruct.wLeftMotorSpeed = speed;
	else if ( motorID==1 )
		mVibrationStruct.wRightMotorSpeed = speed;
	else
	{
		assert(false);
	}
}

}